<template>
    <div class="title">
        <div>ToDoList</div>
        <div><input v-model="addListObj.name" type="text" placeholder="添加ToDo" @keydown.enter="addListFa"></div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import {addList,getList} from "../api/list"
let y =defineProps(['render'])
let addListObj = ref({
    name:"",
    age:0,
    flag:false
})
let addListFa = async ()=>{
    // 发送添加请求
    await addList(addListObj.value) 
    // 重新获取列表
    getList()
    // 添加成功后清空输入框
    addListObj.value.name = '';
   y.render()
}

</script>

<style></style>